//
//  HEOrgConectCell.m
//  HealthFamily
//
//  Created by 吴欧 on 2020/11/26.
//  Copyright © 2020 honglutec. All rights reserved.
//

#import "HEOrgConectCell.h"
#import "HEOldPelOrgModel.h"

@interface HEOrgConectCell ()

@property(nonatomic, strong) UILabel *titleLb;

@property(nonatomic, strong) UILabel *nameLb;
@property(nonatomic, strong) UILabel *conectLb;
@property(nonatomic, strong) UILabel *phoneLb;
@property(nonatomic, strong) UILabel *codeLb;
@property(nonatomic, strong) UILabel *areaLb;
@property(nonatomic, strong) UILabel *addressLb;

@end

@implementation HEOrgConectCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.contentView.backgroundColor = KWhiteColor;
        
        [self initUI];
    }
    return self;
}

- (void)initUI {
    UIView *dotView = [UIView new];
    dotView.backgroundColor = KHexColor(@"FFA900");
    [self.contentView addSubview:dotView];

    [dotView hg_setAllCornerWithCornerRadius: 5];
    
    _titleLb = [UILabel new];
    _titleLb.font = DYBlodFont(18);
    _titleLb.text = @"-";
    _titleLb.textColor = CNavLightBlackColor;
    [self.contentView addSubview:_titleLb];
    
    [dotView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(_titleLb);
        make.left.equalTo(self.contentView).mas_offset(15);
        make.width.mas_offset(10);
        make.height.mas_offset(10);
    }];
    
    [_titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).mas_offset(15);
        make.left.equalTo(dotView.mas_right).mas_offset(10);
        make.right.equalTo(self.contentView).mas_offset(-15);
    }];
    
    [_titleLb setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisVertical];
    
    UILabel *nameLb = [UILabel new];
    nameLb.text = @"联系人：";
    nameLb.font = DYFont(16);
    nameLb.textColor = CNavDargGrayColor;
    [self.contentView addSubview: nameLb];
    
    UILabel *conectLb = [UILabel new];
    conectLb.text = @"固定电话：";
    conectLb.font = DYFont(16);
    conectLb.textColor = CNavDargGrayColor;
    [self.contentView addSubview: conectLb];
    
    UILabel *phoneLb = [UILabel new];
    phoneLb.text = @"手机号码：";
    phoneLb.font = DYFont(16);
    phoneLb.textColor = CNavDargGrayColor;
    [self.contentView addSubview: phoneLb];
    
    UILabel *codeLb = [UILabel new];
    codeLb.text = @"邮政编码：";
    codeLb.font = DYFont(16);
    codeLb.textColor = CNavDargGrayColor;
    [self.contentView addSubview: codeLb];
    
    UILabel *areaLb = [UILabel new];
    areaLb.text = @"所在地区：";
    areaLb.font = DYFont(16);
    areaLb.textColor = CNavDargGrayColor;
    [self.contentView addSubview: areaLb];
    
    UILabel *addressLb = [UILabel new];
    addressLb.text = @"联系地址：";
    addressLb.font = DYFont(16);
    addressLb.textColor = CNavDargGrayColor;
    [self.contentView addSubview: addressLb];
    
    
    _nameLb = [UILabel new];
    _nameLb.text = @"-";
    _nameLb.font = DYFont(16);
    _nameLb.textColor = CNavLightBlackColor;
    _nameLb.numberOfLines = 0;
    [self.contentView addSubview: _nameLb];
    
    _conectLb = [UILabel new];
    _conectLb.text = @"-";
    _conectLb.font = DYFont(16);
    _conectLb.textColor = CNavLightBlackColor;
    _conectLb.numberOfLines = 0;
    [self.contentView addSubview: _conectLb];
    
    _phoneLb = [UILabel new];
    _phoneLb.text = @"-";
    _phoneLb.font = DYFont(16);
    _phoneLb.textColor = CNavLightBlackColor;
    _phoneLb.numberOfLines = 0;
    [self.contentView addSubview: _phoneLb];
    
    _codeLb = [UILabel new];
    _codeLb.text = @"-";
    _codeLb.font = DYFont(16);
    _codeLb.textColor = CNavLightBlackColor;
    _codeLb.numberOfLines = 0;
    [self.contentView addSubview: _codeLb];
    
    _areaLb = [UILabel new];
    _areaLb.text = @"-";
    _areaLb.font = DYFont(16);
    _areaLb.textColor = CNavLightBlackColor;
    _areaLb.numberOfLines = 0;
    [self.contentView addSubview: _areaLb];
    
    _addressLb = [UILabel new];
    _addressLb.text = @"-";
    _addressLb.font = DYFont(16);
    _addressLb.textColor = CNavLightBlackColor;
    _addressLb.numberOfLines = 0;
    [self.contentView addSubview: _addressLb];
    
    
    [nameLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_titleLb.mas_bottom).offset(10);
        make.left.equalTo(self.contentView).mas_offset(15);
    }];
    [nameLb setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];

    [conectLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_nameLb.mas_bottom).offset(10);
        make.left.equalTo(self.contentView).mas_offset(15);
    }];
    [conectLb setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];

    [phoneLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_conectLb.mas_bottom).offset(10);
        make.left.equalTo(self.contentView).mas_offset(15);
    }];
    [phoneLb setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
    
    [codeLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_phoneLb.mas_bottom).offset(10);
        make.left.equalTo(self.contentView).mas_offset(15);
    }];
    [codeLb setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
    
    [areaLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_codeLb.mas_bottom).offset(10);
        make.left.equalTo(self.contentView).mas_offset(15);
    }];
    [areaLb setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
    
    [addressLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_areaLb.mas_bottom).offset(10);
        make.left.equalTo(self.contentView).mas_offset(15);
    }];
    [addressLb setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
    
    
    
    [_nameLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_titleLb.mas_bottom).offset(10);
        make.left.equalTo(nameLb.mas_right);
        make.right.equalTo(self.contentView).offset(-10);
    }];
    
    [_conectLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_nameLb.mas_bottom).offset(10);
        make.left.equalTo(conectLb.mas_right);
        make.right.equalTo(self.contentView).offset(-10);
    }];
    
    [_phoneLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_conectLb.mas_bottom).offset(10);
        make.left.equalTo(phoneLb.mas_right);
        make.right.equalTo(self.contentView).offset(-10);
    }];
    
    [_codeLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_phoneLb.mas_bottom).offset(10);
        make.left.equalTo(codeLb.mas_right);
        make.right.equalTo(self.contentView).offset(-10);
    }];
    
    [_areaLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_codeLb.mas_bottom).offset(10);
        make.left.equalTo(areaLb.mas_right);
        make.right.equalTo(self.contentView).offset(-10);
    }];
    
    [_addressLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_areaLb.mas_bottom).offset(10);
        make.left.equalTo(addressLb.mas_right);
        make.right.equalTo(self.contentView).offset(-10);
        make.bottom.equalTo(self.contentView).offset(-10);
    }];
}

- (void)refreshContent:(GDFiterCellModel *)fiterModel formModel:(GDFormModel *)formModel indexPath:(NSIndexPath *)indexPath {
 
    _titleLb.text = fiterModel.leftTitle;
}

- (void)configCellWithModel:(HEOldPelOrgModel *)model {
    _nameLb.text = model.lxr;
    _conectLb.text = [self notNull:model.gddh];
    _phoneLb.text = model.yddh;
    _codeLb.text = model.yb;
    _areaLb.text = model.xq;
    _addressLb.text = model.xxdz;
}

- (NSString *)notNull:(NSString *)text {
    return [DYTools isBlankString:text] ? @"-":text;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
